package com.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.service.ServiceOne;
import com.service.ServiceTwo;

@Api(value = "测试server接口" , tags = "测试server接口")
@CrossOrigin/*允许跨域请求*/
@RestController
@RequestMapping("test")
public class ServerOne {
    @Autowired
    private ServiceOne serviceOne;
    @Autowired
    private ServiceTwo serviceTwo;

    @ApiOperation(value = "get显示接口1的数据")
    @GetMapping("showAll")
    public String  intoServerOne() {
        return "进入server1 成功 ; "+printOtherService();
    }

    @ApiOperation(value = "post显示接口1的数据")
    @PostMapping("showAll")
    public String  intoServerTwo() {
        return "进入server1 成功 ; "+printOtherService();
    }
    private String printOtherService(){
        StringBuilder strBui = new StringBuilder();
        strBui.append(serviceOne.printService1());
        strBui.append("; ");
        strBui.append(serviceTwo.printService2());
       return strBui.toString();
    }

}
